﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Xml.Serialization;

namespace PlanningGIS.Util.IO
{
    /// <summary>
    /// 
    /// </summary>
    public class XmlHelper
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static string GetXmlAttributeColName(MemberInfo info)
        {
            XmlAttributeAttribute xmlAttr;
            string colName;
            if (Attribute.GetCustomAttributes(info, typeof(XmlAttributeAttribute)).GetLength(0) > 0)
            {
                xmlAttr = Attribute.GetCustomAttributes(info, typeof(XmlAttributeAttribute))[0] as XmlAttributeAttribute;
                if (xmlAttr.AttributeName != "")
                {
                    colName = xmlAttr.AttributeName;
                }
                else
                {
                    colName = info.Name;
                }
            }
            else
            {
                colName = info.Name;
            }
            return colName;
        }
    }
}
